#import "ReportCache.h"

@interface CKIMMessage
- (_Bool) isSMS;
- (long long) rowID;
@end

_Bool check_message_delivery(long long rowid) {
    return [DeliveryReportCache reportForRowid:rowid];
}

%hook CKIMMessage

- (_Bool) isDelivered {
    NSLog(@"is delivered row Id = %lld", self.rowID);
    return check_message_delivery(self.rowID);
}

// not called
- (NSDate *)timeDelivered {
    %log;
    NSDate *t = %orig;
    if (t == nil)
        t = [NSDate date];
    return t;
}
%end

// vim: ft=objc ts=4 expandtab
